<?php

namespace App\Http\Requests\Logic\User;

use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Http\FormRequest;

class UserPermission extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
//        $user = Auth::user();
//        if ($user->hasCompany()) {
//            return true;
//        }
//        return false;
        return true;
    }

    /**
     * 定义验证规则
     *
     * Date: 2018/5/30
     * @author George
     * @return array
     */
    public function rules()
    {
        return [
            'user_id' => 'required',
            'projects_id' => 'nullable|array',
            'permissions_code' => 'nullable|array',
        ];
    }

    /**
     * 定义错误提示信息
     *
     * Date: 2018/5/30
     * @author George
     * @return array
     */
    public function messages()
    {
        return [
            'user_id.required' => '请选择用户',
            'projects_id.array' => '指定的项目集合有误',
            'permission_code' => '制定权限集合有误',
        ];
    }
}
